//
//  XMMessageImageTableCell.m
//  XMMessageKit
//
//  Created by lishi on 2019/3/5.
//  Copyright © 2019 lishi. All rights reserved.
//

#import "XMMessageImageTableCell.h"

//
#import "Masonry.h"
#import "UIImageView+WebCache.h"

@interface XMMessageImageTableCell ()

// 聊天信息
@property (nonatomic, strong) UIImageView *messageImageView;

@end

@implementation XMMessageImageTableCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
//        [self reloadDefultMeeageCell];
        [self reloadDefultMeeageKitCell];
    }
    return self;
}

- (void)setUpValueForCellMessageWithModel:(XMMessageModel *)model {
    self.messageNameLabel.text = model.messageName;
    [self.messageImageView sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@",model.messageUrl]] placeholderImage:nil];
}

- (void)reloadDefultMeeageKitCell {
    [super reloadDefultMeeageKitCell];
    [self.contentView addSubview:self.messageImageView];
    [self.messageImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.messageNameLabel.mas_bottom).offset(10);
        make.left.mas_equalTo(self.messageHeadImageView.mas_right).offset(5);
        make.right.bottom.mas_equalTo(self.contentView).offset(-15);
        make.height.offset(200);
    }];
    
//    self.messageNameLabel.text = @"小小明";
//    [self.messageImageView sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"https://bpic.588ku.com/element_origin_min_pic/19/01/29/7d2f1d42a79ae72fced87cf891d112a3.jpg"]] placeholderImage:nil];
}

//- (void)reloadDefultMeeageCell {
//    [super reloadDefultMeeageCell];
//    [self.contentView addSubview:self.messageImageView];
//    [self.messageImageView mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.top.mas_equalTo(self.messageNameLabel.mas_bottom).offset(10);
//        make.left.mas_equalTo(self.messageHeadImageView.mas_right).offset(5);
//        make.right.bottom.mas_equalTo(self.contentView).offset(-15);
//        make.height.offset(200);
//    }];
//
//    self.messageNameLabel.text = @"小明";
//    [self.messageImageView sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"https://bpic.588ku.com/element_origin_min_pic/19/01/29/7d2f1d42a79ae72fced87cf891d112a3.jpg"]] placeholderImage:nil];
//}

- (UIImageView *)messageImageView {
    if (!_messageImageView) {
        _messageImageView = [[UIImageView alloc] init];
        _messageImageView.backgroundColor = [UIColor orangeColor];
        _messageImageView.contentMode = UIViewContentModeScaleAspectFit;
    }
    return _messageImageView;
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
